package cn.edu.njust.strategy;

import cn.edu.njust.server.Stat;

import java.util.List;

public class LeastLatencyStrategy implements StatelessStrategy {
    @Override
    public int next(List<Stat> stats, List<Integer> weights) {
        long minLatency = stats.get(0).getLastLatency();
        int minIndex = 0;

        Stat stat = null;
        for (int i = 1; i < stats.size(); i++) {
            stat = stats.get(i);
            if (minLatency > stat.getLastLatency()) {
                minLatency = stat.getLastLatency();
                minIndex = i;
            }
        }
        return minIndex;
    }
}
